<?php

class Gl_AreaController extends Controller
{

    /*
    * 获取省列表
    *
    */
    public function actionGetProvinceList()
    {
        try {
            //参数验证

            //检测
            //$user_id = SessionService::getUserIDBySessionid();


            //获取列表
            $searchsql = Util::initSearchSql();

            $searchsql = Util::getSerarchStrAdd($searchsql,"level","1");

            //排序
            $searchsql = $searchsql . " order by sort ";
            //获取list
            $list = GlArea::model()->findAll($searchsql);


	             //返回数据
	             Util::responseList(count($list), $list);


	         } catch (Exception $e) {
            Util::responseErrorMsg($e->getMessage());

        }
    }

    /*
   * 获取市列表
   *
   */
    public function actionGetCityList()
    {
        try {
            //参数验证
            $parentid = Util::getParamNotEmpty("parentid");

            //检测
            //$user_id = SessionService::getUserIDBySessionid();


            //获取列表
            $searchsql = Util::initSearchSql();

            $searchsql = Util::getSerarchStrAdd($searchsql,"level","2");
            $searchsql = Util::getSerarchStrAdd($searchsql,"parentid",$parentid);

            //排序
            $searchsql = $searchsql . " order by sort ";
            //获取list
            $list = GlArea::model()->findAll($searchsql);


            //返回数据
            Util::responseList(count($list), $list);


        } catch (Exception $e) {
            Util::responseErrorMsg($e->getMessage());

        }
    }

    /*
  * 获取区列表
  *
  */
    public function actionGetRegionList()
    {
        try {
            //参数验证
            $parentid = Util::getParamNotEmpty("parentid");

            //检测
            //$user_id = SessionService::getUserIDBySessionid();


            //获取列表
            $searchsql = Util::initSearchSql();

            $searchsql = Util::getSerarchStrAdd($searchsql,"level","3");
            $searchsql = Util::getSerarchStrAdd($searchsql,"parentid",$parentid);

            //排序
            $searchsql = $searchsql . " order by sort ";
            //获取list
            $list = GlArea::model()->findAll($searchsql);


            //返回数据
            Util::responseList(count($list), $list);


        } catch (Exception $e) {
            Util::responseErrorMsg($e->getMessage());

        }
    }



}